package cn.xiaopengstack.domain.order.model.aggregate;

import cn.xiaopengstack.domain.order.model.entity.OrderEntity;
import cn.xiaopengstack.domain.order.model.entity.ProductEntity;
import cn.xiaopengstack.domain.order.model.entity.ShopCarEntity;
import cn.xiaopengstack.domain.order.model.valobj.PayOrderStatusEnumVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

import java.util.Date;

/**
 * @author jiangyangang
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CreateOrderAggregate {

    private ShopCarEntity shopCarEntity;

    private OrderEntity orderEntity;

    private ProductEntity productEntity;

    public static OrderEntity buildInitOrderEntity(String productId, String productName){
        return OrderEntity.builder()
                .orderStatusVO(PayOrderStatusEnumVO.create)
                .orderTime(new Date())
                .orderId(RandomStringUtils.randomNumeric(14))
                .productId(productId)
                .productName(productName)
                .build();
    }
}
